home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
pcl_src.zoo
/
low.lsp
< prev
next >
Wrap
Text File
|
1992-09-09
|
33KB
|
738 lines
;;;-*-Mode:LISP; Package:(PCL LISP 1000); Base:10; Syntax:Common-lisp -*-
;;;
;;; *************************************************************************
;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
;;; All rights reserved.
;;;
;;; Use and copying of this software and preparation of derivative works
;;; based upon this software are permitted. Any distribution of this
;;; software or derivative works must comply with all applicable United
;;; States export control laws.
;;;
;;; This software is made available AS IS, and Xerox Corporation makes no
;;; warranty about the software, its performance or its conformity to any
;;; specification.
;;;
;;; Any person obtaining a copy of this software is requested to send their
;;; name and post office or electronic mail address to:
;;; CommonLoops Coordinator
;;; Xerox PARC
;;; 3333 Coyote Hill Rd.
;;; Palo Alto, CA 94304
;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
;;;
;;; Suggestions, comments and requests for improvements are also welcome.
;;; *************************************************************************
;;;
;;; This file contains portable versions of low-level functions and macros
;;; which are ripe for implementation specific customization. None of the
;;; code in this file *has* to be customized for a particular Common Lisp
;;; implementation. Moreover, in some implementations it may not make any
;;; sense to customize some of this code.
;;;
;;; But, experience suggests that MOST Common Lisp implementors will want
;;; to customize some of the code in this file to make PCL run better in
;;; their implementation. The code in this file has been separated and
;;; heavily commented to make that easier.
;;;
;;; Implementation-specific version of this file already exist for:
;;;
;;; Symbolics Genera family genera-low.lisp
;;; Lucid Lisp lucid-low.lisp
;;; Xerox 1100 family xerox-low.lisp
;;; ExCL (Franz) excl-low.lisp
;;; Kyoto Common Lisp kcl-low.lisp
;;; Vaxlisp vaxl-low.lisp
;;; CMU Lisp cmu-low.lisp
;;; H.P. Common Lisp hp-low.lisp
;;; Golden Common Lisp gold-low.lisp
;;; Ti Explorer ti-low.lisp
;;;
;;;
;;; These implementation-specific files are loaded after this file. Because
;;; none of the macros defined by this file are used in functions defined by
;;; this file the implementation-specific files can just contain the parts of
;;; this file they want to change. They don't have to copy this whole file
;;; and then change the parts they want.
;;;
;;; If you make changes or improvements to these files, or if you need some
;;; low-level part of PCL re-modularized to make it more portable to your
;;; system please send mail to CommonLoops.pa@Xerox.com.
;;;
;;; Thanks.
;;;
(in-package 'pcl)
(eval-when (compile load eval)
(defconstant *optimize-speed*
#+kcl
'(optimize)
#-kcl
'(optimize (speed 3) (safety 0) (compilation-speed 0) (space 0))
"List of declarations for locally-optimized internal code.")
)
;;; PCL optimizes slot-value accesses on specialized parameters by caching
;;; methods for each set of classes the method is called on.
;;; *compile-slot-access-method-functions-at-runtime-p* controls whether
;;; July 92 stores the method lambda for such methods and compiles them
;;; at runtime if one of the slot accesses is on a non-:instance allocated
;;; slot, is on a non-standard instance, or has a user-defined
;;; slot-value-using-class method.
;;; Doing so speeds up slot-accesses because each slot access is directly
;;; coded in the cached method to be compiled, at the cost of extra compilation
;;; at runtime. store-optimized-method-lambda-p can also be specialized
;;; for the specific kind of generic-function and methods (see methods.lisp).
;;; The default is normally T, but can be changed.
(declaim (type boolean *compile-slot-access-method-functions-at-runtime-p*))
(defvar *compile-slot-access-method-functions-at-runtime-p* T
"When T tells PCL to store the lambda source for methods containing slot
accesses and to compile those slot accesses at runtime in certain cases.")
;;;
;;; For optimization purposes, July 92 PCL adds the variable
;;; *compile-all-method-functions-p*, that lets a programmer tell PCL
;;; to make sure that all method functions are compiled, and to trust that
;;; they will be compiled. The default is NIL, leaving them compiled or
;;; uncompiled as normal, so people can debug their programs more easily
;;; when loading uncompiled source code.
;;; It can be set to T by a program that uses PCL, but *must* be set
;;; to T before any user methods are loaded (otherwise their method
;;; functions might have been loaded as uncompiled functions, potentially
;;; causing nasty things to happen when the method dispatch functions later
;;; assume that they're compiled). It is safe for a user program to set
;;; it to T after PCL itself is loaded, however, because presumably PCL
;;; will have been loaded as compiled.
(declaim (type boolean *compile-all-method-functions-p*))
(defvar *compile-all-method-functions-p* NIL
"When T tells PCL to compile all cached method-functions and
to assume that they are compiled.")
;;; *compile-all-slot-initfunctions-p* tells whether all slot
;;; definition initfunctions should be compiled. Default is T.
;;; It can be set to T or NIL by a program that uses PCL, but should
;;; *not* ever later be changed to NIL if PCL has been compiled with it
;;; as T, since the initfunction-funcall's for PCL will have assumed that
;;; they are all compiled. Later changing it to T after PCL has been
;;; compiled with NIL if you change it here, however, is safe.
(declaim (type boolean *compile-all-slot-initfunctions-p*))
(defvar *compile-all-slot-initfunctions-p* T
"When T tells PCL to compile all slot initfunctions and assume they are compiled.")
(declaim (type boolean *uncompiled-slot-initfunctions-exists-p*))
(defvar *uncompiled-slot-initfunctions-exist-p* NIL
"Tells whether there have ever been any uncompiled slot initfunctions.")
;;; To adhere to the AMOP while retaining maximum efficiency, method
;;; functions are actually stored in two ways: as a (1) METHOD-FUNCTION and
;;; (2) as a METHOD-OPTIMIZED-FUNCTION or METHOD-CLOSURE-GENERATOR.
;;; METHOD-FUNCTION is the documented function of the AMOP.
;;; METHOD-OPTIMIZED-FUNCTION is the optimized function used by PCL in actual
;;; method function invocation (METHOD-FUNCTION-FOR-CACHING). Its arguments are
;;; the actual arguments of method, and it recieves its next-methods by
;;; looking at the global *NEXT-METHODS*. Alternatively, if the method's
;;; body contains slot-value accesses that can be optimized for caching,
;;; a METHOD-CLOSURE-GENERATOR is stored instead of METHOD-OPTIMIZED-FUNCTION
;;; to generate an optimized caching function for given parameter types.
;;;
;;; To save space and compile time, generic function STORE-METHOD-FUNCTION-P
;;; (generic-function method initargs) can be specialized to return NIL
;;; if the (normally unused) documented method-functions are not needed.
;;; Default returns T. Variable *standard-store-method-function-p*, which
;;; is what the default store-method-function-p method looks up, can be
;;; set to NIL if it is known that documented method functions will never
;;; be needed.
(declaim (type boolean *standard-store-method-function-p*))
(defvar *standard-store-method-function-p* T
"Value used by default STORE-METHOD-METHOD-FUNCTION-P method to tell
whether standard-methods used in standard-generic-functions store
documented method-functions.")
;;; Global variables keeping track of whether it is safe to use the
;;; fast slot-value optimizations that directly lookup slot location
;;; from wrapper (wrapper-optimized-slot-value) or not. PCL changes
;;; the appropriate variable to NIL if the user defines any
;;; sl